<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">主体金额统计</ui:define>
    <ui:define name="content">


        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         update="@form"/>
                        <p:commandButton value="重置" actionListener="#{settlementCompanyAmountListBean.onReset()}" icon="fa fa-refresh"
                                         process="@this" update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="xls" target="statisticRecordDataTable" fileName="主体金额统计"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="主体名称"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu id="companyId" value="#{settlementCompanyAmountListBean.$.companyId}"
                                             filter="true" updateLabel="true"
                                             filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                              noSelectionOption="true"/>
                                <f:selectItems value="#{settlementCompanyAmountListBean.companyList}"
                                               var="dic"
                                               itemLabel="#{dic.companyName}" itemValue="#{dic.id}"/>
                            </p:selectOneMenu>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="结算时间"/>
                        </div>
                        <div class="ui-g-3">
                            <p:calendar
                                    id="startTime" styleClass="autoWidthCalendar"
                                    value="#{settlementCompanyAmountListBean.$.startTime}"
                                    locale="#{constants:get('LOCALE')}"
                                    timeZone="#{constants:get('TIME_ZONE')}"
                                    pattern="#{constants:get('DATE_FORMAT')}"/>
                            <span>—</span>
                            <p:calendar
                                    id="endTime" styleClass="autoWidthCalendar"
                                    value="#{settlementCompanyAmountListBean.$.endTime}"
                                    locale="#{constants:get('LOCALE')}"
                                    timeZone="#{constants:get('TIME_ZONE')}"
                                    pattern="#{constants:get('DATE_FORMAT')}"/>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="创建人"/>
                        </div>
                        <div class="ui-g-3">
                            <p:inputText value="#{settlementCompanyAmountListBean.$.creator}"/>
                        </div>
                    </div>

                    <div class="ui-g-12 card">
                        <p:dataTable id="statisticRecordDataTable"
                                     style="width: 100%;text-align:center"
                                     var="record"
                                     value="#{settlementCompanyAmountListBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true">
                            <p:column headerText="主体流水号">
                                <h:outputText value="#{record.id}"/>
                            </p:column>
                            <p:column headerText="开票主体" style="width: 250px">
                                <h:outputText value="#{record.companyName}"/>
                            </p:column>
                            <p:column headerText="收款金额" style="text-align:center;">
                                <h:outputText value="#{record.prepayAmount==null?0:record.prepayAmount}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="消耗金额" style="text-align:center;">
                                <h:outputText value="#{record.expendAmount==null?0:record.expendAmount}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="剩余金额" style="text-align:center;">
                                <h:outputText value="#{record.prepayAmount - record.expendAmount}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="创建人" style="text-align:center;">
                                <h:outputText value="#{record.creator}"/>
                            </p:column>
                            <p:column headerText="创建时间" style="text-align:center;">
                                <h:outputText value="#{record.createTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                    </div>

                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>